<template>
  <div class="hot-rcmd">
    <theme-header-rcmd 
      title="热门推荐" 
      :keywords="keywords"
    />
    <div class="rcmd-list">
      <template
        v-for="item in hotRecommends"
        :key="item.id"
      >
        <songs-cover
          :item="item"
        />
      </template>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, reactive, ref } from 'vue';
import { useStore } from "@/store";

import { useState } from "@/hooks";

import ThemeHeaderRcmd from "@/components/theme-header-rcmd/index.vue";
import SongsCover from "@/components/songs-cover/index.vue";

export default defineComponent({
  components: {
    ThemeHeaderRcmd,
    SongsCover
  },

  setup() {
    const keywords = reactive([
      { title: "温柔" }, 
      { title: "轻松" }, 
      { title: "欢快" }, 
      { title: "安静" }, 
      { title: "night" }
    ]);
    const store = useStore();

    const { hotRecommends } = useState("recommend", ["hotRecommends"]);

    onMounted(() => {
      store.dispatch("recommend/getHotRecommendAction", 12)
    })

    return {
      keywords,
      hotRecommends
    }
  }
})
</script>

<style lang="less" scoped>
.rcmd-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
</style>